package com.feng.Controller;

import com.feng.domain.ResponseResult;
import com.feng.domain.entity.Article;
import com.feng.service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    private ArticleService articleService;

    /**
     * 查询最热文章
     * @return
     */
    @GetMapping("/hotArticleList")
    public ResponseResult hotArticleList(){
     //查询热门文章，封装ResponseResult返回
        ResponseResult result=articleService.hotArticleList();
        return result;

    }

    /**
     *分页查询文章列表
     * @param pageNum 当前页码
     * @param pageSize 每页文章的显示的条数
     * @param categoryId 分类的id
     * @return
     */
    @GetMapping("/articleList")
    public  ResponseResult articleList(Integer pageNum,Integer pageSize,Long categoryId,String inputContent) {

       return articleService.articleList(pageNum,pageSize,categoryId,inputContent);
    }
    @GetMapping("/{id}")
    public ResponseResult getArticleDetail(@PathVariable Long id){
          return articleService.getArticleDetail(id);
    }

    @PutMapping("/updateViewCount/{id}")
    public ResponseResult updateViewCount(@PathVariable Long id){
        return articleService.updateViewCount(id);
    }
    @GetMapping("/getAllArticleTitle")
    public ResponseResult getAllArticleTitle(){
        return articleService.getAllArticleTitle();
    }
    //查询前四条最新发布文章
    @GetMapping("/updateArticleList")
    public ResponseResult updateArticleList(){
        return articleService.updateArticleList();
    }
}
